package com.example.shengyin.util;

import lombok.Data;

import java.io.Serializable;

/**
 * @author oldliu
 * @since 1.0
 */
//Ajax封装数据
@Data
public class Result implements Serializable {
    //500：错误，403：没有权限，404：没有找到。。。
    private int code = 0;//操作的状态
    private Object data;//操作返回的数据
    private String msg = "操作成功";//操作信息

    public Result() {

    }

    public Result(int code, Object data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }
    public static Result success() {
        return new Result();
    }
    public static Result success(Object data) {
        return new Result(0, data, null);
    }

    public static Result success(Object data, String msg) {
        return new Result(0, data, msg);
    }

    public static Result success(String m) {
        return new Result(0, null, m);
    }

    public static Result error(String m) {
        return new Result(500, null, m);
    }

    public static Result error(int code, String m) {
        return new Result(code, null, m);
    }
}
